package com.harusource.test;

import com.harusource.di.annotation.Event;
import com.harusource.di.annotation.Inject;
import com.harusource.di.core.activity.HaruActivity;

import android.app.AlarmManager;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

/**
 * Sample of using HaruActivity
 * If you want to use @Inject and @Event annotation to inject some dependency,
 * you must create a your Activity from HaruActivity instead of Activity.
 * @author Hiroki Oizumi
 *
 */
public class SampleHaruActivity extends HaruActivity{
    /**
     * Sample of how to inject a instance of some SystemService
     * Just only add @Inject annotation to a field member
     */
    @Inject
    AlarmManager    mAlarmManager;
    
    /**
     * Sample of how to inject a view instance
     * Add @Inject annotation to a field member with related resource id.
     */
    @Inject(id=R.id.textview1)
    TextView mTextView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sample_haru);
    }
    
    /**
     * How to handle a view event
     * Add @Event annotation to a method with a delegate class and related resource id.
     * @param view
     */
    @Event(clazz=View.OnClickListener.class, id=R.id.button1)
    void onClickTextView(View view){
        finish();
    }
}
